package com.itheima.homework;


import java.text.ParseException;

import java.util.Random;

public class demo02 {
    public static void main(String[] args) throws ParseException {
        System.out.println(CreateCode(4));
    }

    public static String CreateCode(int num){
        Random r = new Random();
//        StringBuilder sb = new StringBuilder("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
        StringBuilder sb = new StringBuilder();
        for (char i = 'a'; i <= 'z'; i++) {
            sb.append(i);
        }
        for (char i = 'A'; i <= 'Z'; i++) {
            sb.append(i);
        }
        for (char i = '0'; i <= '9'; i++) {
            sb.append(i);
        }
        System.out.println(sb);
        String code = "";
        for (int i = 0; i < num; i++) {
            code += sb.charAt(r.nextInt(sb.length()));
        }
        return code;
    }
}
